cmake_minimum_required(VERSION 3.5)

project(MeetServiceStart VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES  Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt5 REQUIRED COMPONENTS Widgets)

#include_directories(${PROJECT_SOURCE_DIR}/lib/yaml-cpp/include) #将头文件引入工程

set(PROJECT_SOURCES
        main.cpp
        mainwindow.cpp
        mainwindow.h
        mainwindow.ui
)


add_executable(MeetServiceStart
    ${PROJECT_SOURCES}
    app.rc
)


target_link_libraries(MeetServiceStart PRIVATE Qt5::Widgets)

#set(save_src_dir ${CMAKE_BINARY_DIR})
# 拷贝 src文件夹下的内容  到  save_src_dir 中
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/winBat ${CMAKE_BINARY_DIR})

## 复制 dll 库
#add_custom_command(TARGET MeetServiceStart
#        POST_BUILD
#        COMMAND ${CMAKE_COMMAND} -E copy
#        "${PROJECT_SOURCE_DIR}/winBat/*"
#        "${CMAKE_BINARY_DIR}/yaml-cpp.dll")


#set_target_properties(MeetServiceStart PROPERTIES
#    WIN32_EXECUTABLE TRUE
#    MACOSX_BUNDLE TRUE
#    MACOSX_BUNDLE_ICON_FILE icon.ico
#)

##将库文件引入子工程
#link_libraries(${PROJECT_SOURCE_DIR}/lib/yaml-cpp/include) #将库文件引入工程
#target_link_libraries(MeetServiceStart PRIVATE
#        ${PROJECT_SOURCE_DIR}/lib/yaml-cpp/yaml-cpp.lib
#)

## 复制 dll 库
#add_custom_command(TARGET MeetServiceStart
#        POST_BUILD
#        COMMAND ${CMAKE_COMMAND} -E copy
#        "${PROJECT_SOURCE_DIR}/lib/yaml-cpp/yaml-cpp.dll"
#        "${CMAKE_BINARY_DIR}/yaml-cpp.dll")

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
  set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.MeetServiceStart)
endif()


set_target_properties(MeetServiceStart PROPERTIES
    ${BUNDLE_ID_OPTION}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

include(GNUInstallDirs)
install(TARGETS MeetServiceStart
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(QT_VERSION_MAJOR EQUAL 6)
    qt_finalize_executable(MeetServiceStart)
endif()
